﻿
using System.Numerics;

namespace C__Learn
{
    internal class Program
    {
        static void Main(string[] args)  // C#函数名统一每个单词首字母都大写
        {
            Console.WriteLine("Hello, World!");
            Calculator c = new Calculator();
            int output = Calculator.Add(2, 3);
            Console.WriteLine(output);

            dynamic myVar = 100;
            Console.WriteLine(myVar);
            myVar = "Mr. Okay!";
            Console.WriteLine(myVar);

            int[] array = new int[100];  // 数组
            Console.WriteLine(array[0]);

            //Student stu = new Student(202502733, "Sally");
            //stu.ID = 1;
            //Console.WriteLine(stu.ID);
            //Console.WriteLine(stu.Name);

            //Student stu2 = new Student();
            //Console.WriteLine(stu2.ID);
            //Console.WriteLine(stu2.Name);

            Dictionary<String, Student> stuDic = new Dictionary<string, Student> { };   // 字典
            for (int i = 1; i <= 10; i++)
            {
                Student stu = new Student();
                stu.Name = "s_" + i.ToString();
                stu.Score = 100 + i;
                stuDic.Add(stu.Name, stu);
            }

            Student number6 = stuDic["s_6"];
            Console.WriteLine(number6.Score);

        }
    }

    class Calculator
    {
        private readonly double Pi_7 = 3.1415926;

        public static int Add(int a, int b)
        {
            int result = a + b;
            return result;
        }

        public double GetCircleArea(double r)
        {
            return Pi_7 * r * r;
        }

        //~Calculator()
        //{

        //}
    }

    class Student
    {
        public static int Amount;
        
        public int ID;
        public int Age;
        public string Name;
        public int Score;

        // ctor 按一下TAB键自动生成一个空的构造函数
        public Student()
        {
            this.ID = 1;
            this.Name = "NaN";
        }

        public Student(int initId, string initName)
        {
            this.ID = initId;
            this.Name = initName;
        }

        public T Add<T> (T a, T b) where T : INumber<T>
        {
            T c = a + b;
            return c;
        }
    }
}

// 静态（Static)成员在语义上表示它是“类的成员”
// 实例（非静态）成员在语义表示它是“对象的成员”
// 绑定（Binding）指的是编译器如果把一个成员与类或对象关联起来
    // 早绑定，程序在编译的时候就知道成员是与类还是对象关联
    // 晚绑定，程序在编译的时候不知道，由程序运行起来之后程序员指定

